package com.study.juc;

import java.util.concurrent.*;

public class ThreadPool {
    public static void main(String[] args) {
        ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(
                2,
                4,
                500L,
                TimeUnit.MICROSECONDS,
                new ArrayBlockingQueue<>(10),
                r -> {
                    Thread thread = new Thread(r);
                    thread.setName("aaaaaa");
                    return thread;
                },
                new ThreadPoolExecutor.AbortPolicy()
        );
        threadPoolExecutor.execute(() -> {
            for (int i = 0; i < 10; i++) {
                System.out.println("i = " + i);
            }
        });
        Future<?> submit = threadPoolExecutor.submit(new FutureTask<String>(() -> {
            System.out.println("threadPoolExecutor = " + threadPoolExecutor);
            return null;
        }));
        threadPoolExecutor.shutdown();
    }
}
